/**
 * Controller class for the DVD collection
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * @revised version English (Ab)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */

package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;

public class DVDCtr
{
    private MovieCollection movieCollection;

    /**
     * Constructor for objects of class DVDCtr
     */
    public DVDCtr()
    {
        movieCollection = MovieCollection.getInstance();
    }
    
    /**
     * Finds the movie entry in array via its title.
     * 
     * @param title the movie title to be used in search
     */
    public DVD findDVD(String title)
    {
       return movieCollection.findDVD(title); 
    }
    
    /**
     * Creating a new entry in the dvd array
     * 
     * @param title sets the title for the entry
     * @param director sets the director for the entry
     * @param release sets the release date for the entry
     */
    public void createDVD(String title, String director, String release)
    {       
        DVD DVDObj = new DVD(title, director, release);
        movieCollection.addDVD(DVDObj);
    }
    
    /**
     * Deleting a movie with the use of its title.
     * 
     * @param title the movie title to be used in deleting
     */
    public boolean deleteDVD(String title)
    {
        return movieCollection.deleteDVD(title);
    }
    
    /**
     * Adding a copy in the array.
     * 
     * @param serialNo sets the serialnumber for the enty
     * @param acquisitionDate sets the acquisition date for the entry
     * @param acquisitionPrice sets the acquisition prive for the entry
     */
    public void createCopy(DVD DVDObj, long serialNo, String acquisitionDate, double acquisitionPrice)
    {
        DVDObj.addCopy(serialNo, acquisitionDate, acquisitionPrice);
    }
    
    /**
     * Lists all movies in array.
     */
    public ArrayList<DVD> listAllDvds()
    {
        return movieCollection.listAllDVD();
    }
    
    /**
     * Editing movie information.
     * 
     * @param choise selecting wich part to edit
     * @param newData the data to replace in array
     */
    public void editDVDData(DVD DVDObj, int choice, String newData)
    {
        if (choice == 1)
        {
            DVDObj.setTitle(newData);
        }
        else if (choice == 2)
        {
            DVDObj.setDirector(newData);
        }
        else if (choice == 3)
        {
            DVDObj.setReleaseDate(newData);
        }
    }
}